package com.lijie.bs_recruit.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lijie.bs_recruit.mapper.JobfairCompanyMapper;
import com.lijie.bs_recruit.model.Jobfaircompany;
import com.lijie.bs_recruit.service.JobfairCompanyService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author lijie
 * @since 2021-04-07
 */
@Service
public class JobfairCompanyServiceImpl extends ServiceImpl<JobfairCompanyMapper, Jobfaircompany> implements JobfairCompanyService {

    @Override
    public Jobfaircompany selJobfaircompanyByIds(Integer jobFairId, Integer companyId) {
        Jobfaircompany jobfaircompany=null;
        if(jobFairId!=null&&companyId!=null){
            QueryWrapper<Jobfaircompany> wrapper=new QueryWrapper<>();
            wrapper.eq("jobfairId", jobFairId)
                    .eq("companyId",companyId);
            jobfaircompany = baseMapper.selectOne(wrapper);
        }
        return jobfaircompany;
    }

    @Override
    public Boolean addJobFairBusiness(Jobfaircompany jobfaircompany) {
        int insert = baseMapper.insert(jobfaircompany);
        return insert>0;
    }

    @Override
    public PageInfo<Jobfaircompany> selectJobFair(Integer pageIndex, Jobfaircompany jobfaircompany) {
        List<Jobfaircompany> jobfaircompanies = baseMapper.selJobfairbusiness(jobfaircompany.getJobfairId());
        PageHelper.startPage(pageIndex,8);
        PageInfo<Jobfaircompany> pageInfo = new PageInfo<>(jobfaircompanies);
        return pageInfo;
    }

    @Override
    public Boolean delJobFairBusiness(Jobfaircompany jobfaircompany) {
        return null;
    }
}
